﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class MarketConfig extends Object
    {
        private var _map:Dictionary;
        private static var _instance:MarketConfig;

        public function MarketConfig()
        {
            this._map = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" MarketConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TMarket = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                if (this._map[_loc_3.market1] == null)
                {
                    this._map[_loc_3.market1] = new Dictionary();
                }
                _loc_2 = new TMarket();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._map[_loc_2.market1][_loc_2.market2] = _loc_2;
            }
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_market.json");
            this.write(_loc_1);
            return;
        }// end function

        public function getInfoById(param1:int) : TMarket
        {
            return this._map[param1];
        }// end function

        public function get map() : Dictionary
        {
            return this._map;
        }// end function

        public static function get instance() : MarketConfig
        {
            if (_instance == null)
            {
                _instance = new MarketConfig;
            }
            return _instance;
        }// end function

        public static function decodeItemType(param1:TMarket) : Array
        {
            var _loc_5:String = null;
            var _loc_2:Array = [];
            var _loc_3:* = param1.itemType.split("&");
            var _loc_4:int = 0;
            while (_loc_4 < _loc_3.length)
            {
                
                _loc_5 = _loc_3[_loc_4];
                _loc_5 = _loc_5 + "#";
                _loc_2.push(_loc_5);
                _loc_4++;
            }
            return _loc_2;
        }// end function

    }
}
